package com.lhn.formssi.util;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.Writer;
import java.text.SimpleDateFormat;
import java.util.Date;

public class SystemLogUtil {
	
	//写入系统日志
	public static boolean logWriter(String str) {
		File file = new File("E:\\sts-workspace\\spring-boot-formssi\\formssi\\src\\datas\\log.txt");
		Writer writer = null;
		try {
			if(!file.exists()) {
				file.createNewFile();
			}
			writer = new FileWriter(file, true); 
			Date date = new Date();
			SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); 
			writer.write(str + sf.format(date) + "\r\n");
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} finally {
			if(writer != null) {
				try {
					writer.close();
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
		}
		return true;
	}
}
